<script>
function swap(x,y) {
  temp = x; x = y; y = temp;
  return x;
}
var x = 1; var y = 2; var z = swap(x,y); 
alert(x); alert(y); alert(z);
</script>

